package com.zaofan.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zaofan.bean.BaiLocation;
import com.zaofan.utils.JsonUtils;
import com.zaofan.utils.Send;

@WebServlet("/position")
public class PositionController extends BaseServlet {
	private static final long serialVersionUID = 1L;

	protected void location(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try {
			String address = request.getParameter("address");
			String city = request.getParameter("city");
			if (address == null || city == null) {
				JsonUtils.writeListFailJson("查询失败!!", response);
				return;
			}
			BaiLocation location = Send.getLocation(address, city);
			JsonUtils.writeSuccessJson("查询成功", location, response);
		} catch (Exception e) {
			e.printStackTrace();
			JsonUtils.writeBeanFailJson("参数错误!!", response);
		}
		JsonUtils.writeBeanFailJson("查询失败!!", response);
	}

}
